package com.lc202309;

/**
 * Description:
 *
 * @Create 2023/9/14 22:24
 * @Version 1.0
 */
public class Solution171 {
    public int titleToNumber(String columnTitle) {
        int length = columnTitle.length();
        int res = 0;
        int k;
        for (int i = 0; i < length; i++) {
            k = columnTitle.charAt(i) - 'A' + 1;
            res = (int) (res + k * Math.pow(26, length - i - 1));
        }
        return res;
    }
}
